package org.tongdao.yulong.basic_di.complexfield;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

/**
 * @Description: TODO
 * @author: 殷玉龙
 * @date: 2020年09月29日 10:50 上午
 */
@Configuration
@ComponentScan
public class InjectComplexFieldConfiguration {

  @Bean
  @Autowired
  @Qualifier("administrator")//指定注入的bean
  public Cat cat(Person person){
    Cat cat = new Cat();
    cat.setName("da cat");
    cat.setPerson(person);
    return cat;
  }

  @Bean
  @Primary//默认注入bean
  public Person master(){
    Person master = new Person();
    master.setName("master");
    return master;
  }
}
